
import fs from 'fs';
import path from 'path';
import { loadBlogData } from '../utils';

export default async (req, res) => {
    try {

        const { category } = req.query; // 从请求中获取动态路由参数 c
        const blogData=loadBlogData();

        const blogs=blogData.filter(blog=> blog.category.indexOf(category)!==-1)
        

        res.status(200).json( {
            'blogs' : blogs
        });
    } catch (error) {
        res.status(error.response?.status || 500).json({ error: error.message });
    }
  };